<template>
    <div >
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
                  <van-list v-model="loading"
                    :finished="finished"
                    finished-text="没有更多数据"
                    @load="onload"
                    :immediate-check='false'
                    style="margin-bottom: 50px;">
                    <van-cell v-for="(item,index) in list" :key="index" 
                        @click='gotoszjsDetail(index,item)'>
                        <div class="titlefont"> {{item.configDeptName}}</div>
                        <div class="infosfont"> 谈话或走访时间:{{item.talkTime}}</div>
                        <div class="infosfont"> 谈话或走访地点:{{item.talkAddress}}</div>
                        <div class="infosfont"> 谈话或走访对象:{{item.configTime}}</div>
                        <div class="infosfont"> 座谈人数:{{item.numberOfPanel}}</div>
                        <div class="infosfont"> 填报人:{{item.applyUser}}</div>
                        <div class="infosfont"> 填报时间:{{item.applyTime}}</div>
                    </van-cell>

                  </van-list>
              </van-pull-refresh>
    </div>
</template>
<script>
import {getszjstaizhang} from '@/api/gettodo'
import {mapGetters} from 'vuex'
import { Notify } from 'vant'
export default {
    name:'tabview2',
    data(){
        return{
            list:[],
            refreshing:false,
            loading:false,
            finished:false,
            getListQuery:{source:"MOBILE",page:1,rows:10,size:10},
            maxpage:100,
            companyName:'',
            companyCode:'',
            configDeptName:'',
            startTime:'',
            endTime:'',
            talkTime:'',
        }
    },
    computed:{
        ...mapGetters(['user']),
    },
    created(){
        console.log('createdcreatedcreated');
        this.refreshing=true;
        this.finished=false;
        this.loading=true;
        this.getListQuery.page=1;
        this.maxpage=100;
        this.list=[];
        this.onload();
    },
    methods:{
         setsearchdata(companyName,companyCode,configDeptName,startTime,endTime,talkTime){
             console.log('2222222222')
             this.companyName=companyName;
             this.companyCode=companyCode;
             this.configDeptName=configDeptName;
             this.talkTime=talkTime;
             this.startTime=startTime;
             this.endTime=endTime;   
             this.onRefresh();
         },   
         onload(){
            if(this.refreshing){
                    this.list=[];
                    this.refreshing =false
                }

            if(this.getListQuery.page<=this.maxpage){    
                   getszjstaizhang(Object.assign(this.getListQuery,
                {userName:this.user.userName},
                {companyName:this.companyName},
                {companyCode:this.companyCode},
                {configDeptName:this.configDeptName},
                {talkTime:this.talkTime},
                {startTime:this.startTime},
                {endTime:this.endTime}
                ))
                .then((result)=>{
                    if(!result.data){
                        this.loading=false;
                        this.finished=true;
                        Notify(result.message);
                        return;
                    }
                    let listdata =this.list;
                    if(this.getListQuery.page==1){
                        listdata=[];
                        if(result.data.data.content){
                            listdata=result.data.data.content;
                        }
                        this.maxpage=result.data.data.totalPages;
                    }else{
                        if(result.data.data.content){
                            listdata = listdata.concat(result.data.data.content);
                        }
                    }
                    this.list = listdata;
                    console.log(this.list);
                    this.loading = false;
                     this.getListQuery.page=this.getListQuery.page+1;
                });
            }else{
                    this.finished=true;
                    this.loading = false;
                }
        },
        onRefresh(){
            this.finished=false;
            this.refreshing=true;
            this.loading=true;
            this.getListQuery.page=1;
            this.maxpage=100;
            this.onload();
        },gotoszjsDetail(index,item){
            console.log(index,item.id);
            this.$router.push(
                {
                    name:'szjsdetail',
                    params:{
                        szjsdetailid:item.id,
                        isdraw:false,
                    }
                }
            );
        },
    }
}
</script>
<style scoped>
.btn{
     margin-bottom: 60px;
     margin-top: 60px;
 }

</style>